package com.jiazhong.project.servlet;

import com.jiazhong.project.pojo.User;
import com.jiazhong.project.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/registerServlet")
public class RegisterServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username= req.getParameter("username");
        String password=req.getParameter("password");
        String gender = req.getParameter("gender");
        String addr = req.getParameter("addr");
        User user=new User();
        user.setUsername(username);
        user.setPassword(password);
        user.setGender(gender);
        user.setAddr(addr);

        UserService userService=new UserService();
        userService.register(user);
        req.getRequestDispatcher("/login.html").forward(req,resp);
    }
}
